package com.dios.mirage.content;

import java.io.InputStream;

import javax.microedition.media.Manager;
import javax.microedition.media.Player;
import javax.microedition.media.control.VideoControl;

import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.component.Dialog;

public class VideoContent extends Content {

	public static final String PROFILE = "profile.3gp";
	public static final String TVC = "tvc.3gp";

	private Player player;
	private VideoControl videoControl;
	private String url = "/video/";

	public VideoContent(String video) {
		url += video;
		init();
	}
	
	public void init(){
		try {
			// Create a new Player pointing to the video file.
			// This can use any valid URL.
			InputStream is = getClass().getResourceAsStream(url);
			player = Manager.createPlayer(is, "video/3gpp");
			player.realize();

			// Create a new VideoControl.
			videoControl = (VideoControl) player.getControl("VideoControl");
			// Initialize the video mode using a Field.
			Field field = (Field) videoControl.initDisplayMode(
					VideoControl.USE_GUI_PRIMITIVE,
					"net.rim.device.api.ui.Field");

			add(field);

			// Set the video control to be visible.
			videoControl.setVisible(true);
		} catch (Exception ex) {
			Dialog.alert(ex.getMessage());
		}
	}

	public void createGUI() {
		
	}
}
